<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%String path = request.getContextPath();%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${tabTitle}</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <form id="ins_cfg_info_edit_form_ylbank">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">机构名称</div>
                        <div class="field">
                            <span>${fundRasInsNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">客户名称</div>
                        <div class="field">
                            <span>${cstNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">身份证号</div>
                        <div class="field">
                            <span>${certNo}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">身份证地址</div>
                        <div class="field">
                            <jsp:include page="../../system/sysRegion/region.jsp" flush="true">
                                <jsp:param name="regionShowLvl" value="2"/>
                            </jsp:include>
                            <input name="idAddr" id="idAddr" type="text" class="ui-textbox" value="${idAddr}"
                                   validate="{required:true}" placeholder="详细地址" style="width: 400px;">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>

                    <div class="fieldBox col_50">
                        <div class="label">家庭地址</div>
                        <div class="field">
                            <jsp:include page="../../system/sysRegion/regionSecUse.jsp" flush="true">
                                <jsp:param name="regionSecUseShowLvl" value="2"/>
                            </jsp:include>
                            <input name="postAddr" id="postAddr" type="text" class="ui-textbox" value="${postAddr}"
                                   validate="{required:true}" placeholder="详细地址" style="width: 400px;">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">证件签发机关</div>
                        <div class="field">
                            <input name="issuingOrg" id="issuingOrg" type="text" class="ui-textbox"
                                   value="${issuingOrg}" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">证件有效起始日期</div>
                        <div class="field">
                            <input name="certValidSDt" id="certValidSDt" type="text" class="ui-datepicker"
                                   value="${certValidSDt}" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">证件有效终止日期</div>
                        <div class="field">
                            <input name="certValidEDt" id="certValidEDt" type="text" class="ui-datepicker"
                                   value="${certValidEDt}">
                            <div><input type="checkbox" name="checkOne" id="checkOne"
                                        <c:if test="${certValidEDt=='长期'}">checked</c:if> value="长期"
                                        onchange="enduring(this)">长期
                            </div>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">民族</div>
                        <div class="field">
                            <select name="nation" id="nation" value="${nation}" validate="{required:true}">
                                <c:if test="${nation == null || nation == ''}">
                                    <option value=" " selected="selected">--请选择--</option>
                                </c:if>
                                <c:if test="${nation != null && nation != ''}">
                                    <option value=" ">--请选择--</option>
                                </c:if>
                                <c:forEach items="${nationList}" var="item">
                                    <c:if test="${item.value == nation}">
                                        <option value="${item.value}" selected="selected">${item.value}</option>
                                    </c:if>
                                    <c:if test="${item.value != nation}">
                                        <option value="${item.value}">${item.value}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">学历</div>
                        <div class="field">
                            <select name="highDgCd" id="highDgCd" value="${highDgCd}" validate="{required:true}">
                                <c:if test="${highDgCd == null || highDgCd == ''}">
                                    <option value=" " selected="selected">--请选择--</option>
                                </c:if>
                                <c:if test="${highDgCd != null && highDgCd != ''}">
                                    <option value=" ">--请选择--</option>
                                </c:if>
                                <c:forEach items="${highDgCdList}" var="item">
                                    <c:if test="${item.key == highDgCd}">
                                        <option value="${item.key}" selected="selected">${item.value}</option>
                                    </c:if>
                                    <c:if test="${item.key != highDgCd}">
                                        <option value="${item.key}">${item.value}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">行业</div>
                        <div class="field">
                            <select name="indCd" id="indCd" value="${indCd}" validate="{required:true}">
                                <c:if test="${indCd == null || indCd == ''}">
                                    <option value=" " selected="selected">--请选择--</option>
                                </c:if>
                                <c:if test="${indCd != null && indCd != ''}">
                                    <option value=" ">--请选择--</option>
                                </c:if>
                                <c:forEach items="${indCdList}" var="item">
                                    <c:if test="${item.key == indCd}">
                                        <option value="${item.key}" selected="selected">${item.value}</option>
                                    </c:if>
                                    <c:if test="${item.key != indCd}">
                                        <option value="${item.key}">${item.value}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">月收入</div>
                        <div class="field">
                            <input name="monthInc" id="monthInc" type="text" class="ui-textbox" value="${monthInc}" validate="{number:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_100" style="display: none;">
                        <div class="field">
                            <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${prjId}">
                            <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
                            <input name="insCode" id="insCode" type="text" class="ui-textbox" value="${insCode}">
                            <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
                            <input name="cstAccInfoId" id="cstAccInfoId" type="text" class="ui-textbox"
                                   value="${cstAccInfoId}">
                            <input name="fundRasInsId" id=fundRasInsId type="text" class="ui-textbox"
                                   value="${fundRasInsId}">
                        </div>
                    </div>
                </div>
                <div id="saveInsCfgDiv" class="btnsBox">
                    <span id="saveInsCfg" class="sq-button sq-button-round" onclick="return saveInfo();">保存</span>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    var detailFlag = '${detailFlag}';
    var certValidEDt;
    $(function () {
        initData();
        enduring();
    });

    function initData() {
        $("#ins_cfg_info_edit_form_ylbank").ligerForm({
            validate: true
        });
        disabledInput();
        //设置省、市
        setRgnProvCdUpdataValue('${domicileProvince}');
        setRgnCityCdUpdataValue('${domicileCity}');
        setRgnProvCdSecUseUpdataValue('${postProvince}');
        setRgnCityCdSecUseUpdataValue('${postCity}');
    }

    function disabledInput() {
        //流程附件页面
        if (detailFlag == "true") {
            liger.get("rgnProvCd").setDisabled();
            liger.get("rgnCityCd").setDisabled();
            liger.get("rgnProvCdSecUse").setDisabled();
            liger.get("rgnCityCdSecUse").setDisabled();
            liger.get("idAddr").setDisabled();
            liger.get("issuingOrg").setDisabled();
            liger.get("postAddr").setDisabled();
            liger.get("nation").setDisabled();
            liger.get("certValidSDt").setDisabled();
            liger.get("certValidEDt").setDisabled();
            liger.get("monthInc").setDisabled();
            liger.get("indCd").setDisabled();
            liger.get("highDgCd").setDisabled();
            $("#saveInsCfgDiv").hide();
        }
    }

    // 保存项目客户信息，后面弹出准入验证的资料确认页
    function saveInfo() {
        var ligerForm = liger.get("ins_cfg_info_edit_form_ylbank");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }

        if (!getRgnProvCd()) {
            top.$.ligerDialog.SQalert({content: "请填写身份证所在地省!", SQ_type: "error"});
            return false;
        }
        if (!getRgnCityCd()) {
            top.$.ligerDialog.SQalert({content: "请填写身份证所在地市!", SQ_type: "error"});
            return false;
        }
        if (!getRgnProvCdSecUse()) {
            top.$.ligerDialog.SQalert({content: "请填写家庭地址所在地-省!", SQ_type: "error"});
            return false;
        }
        if (!getRgnCityCdSecUse()) {
            top.$.ligerDialog.SQalert({content: "请填写家庭地址所在地-市!", SQ_type: "error"});
            return false;
        }
        if (!$("#idAddr").val() || StringUtils.isEmpty($("#idAddr").val())) {
            top.$.ligerDialog.SQalert({content: "请填写身份证详细地址!", SQ_type: "error"});
            return false;
        }
        if (!$("#issuingOrg").val() || StringUtils.isEmpty($("#issuingOrg").val())) {
            top.$.ligerDialog.SQalert({content: "请填写证件签发机关!", SQ_type: "error"});
            return false;
        }
        if (!$("#postAddr").val() || StringUtils.isEmpty($("#postAddr").val())) {
            top.$.ligerDialog.SQalert({content: "请填写家庭地址详细地址!", SQ_type: "error"});
            return false;
        }
        if (!$("#nation").val() || StringUtils.isEmpty($("#nation").val())) {
            top.$.ligerDialog.SQalert({content: "请填写民族!", SQ_type: "error"});
            return false;
        }
        if (!$("#certValidSDt").val() || StringUtils.isEmpty($("#certValidSDt").val())) {
            top.$.ligerDialog.SQalert({content: "请填写证件有效起始日期!", SQ_type: "error"});
            return false;
        }
        if (null == certValidEDt && !$("#certValidEDt").val()) {
            top.$.ligerDialog.SQalert({content: "请选择证件有效终止日期！", SQ_type: "error"});
            return false;
        }
        if (!$("#monthInc").val() || StringUtils.isEmpty($("#monthInc").val())) {
            top.$.ligerDialog.SQalert({content: "请填写月收入!", SQ_type: "error"});
            return false;
        }
        if (!$("#indCd").val() || StringUtils.isEmpty($("#indCd").val())) {
            top.$.ligerDialog.SQalert({content: "请填写行业!", SQ_type: "error"});
            return false;
        }
        if (!$("#highDgCd").val() || StringUtils.isEmpty($("#highDgCd").val())) {
            top.$.ligerDialog.SQalert({content: "请填写学历!", SQ_type: "error"});
            return false;
        }

        var data = ligerForm.getData();
        data["cstAccInfoId"] = $("#cstAccInfoId").val();//项目客户账户id
        data["prjId"] = $("#prjId").val();//项目id
        data["cstId"] = $("#cstId").val();//客户id
        data["insCode"] = $("#insCode").val();//机构code
        data["fundRasInsId"] = $("#fundRasInsId").val();//机构
        data["certNo"] = $("#certNo").val();//身份证号
        data["cstNm"] = $("#cstNm").val();//客户名称
        data["domicileProvince"] = getRgnProvCd();//身份证所在省
        data["domicileCity"] = getRgnCityCd();//身份证所在市
        data["postProvince"] = getRgnProvCdSecUse();
        data["postCity"] = getRgnCityCdSecUse();
        data["idAddr"] = $("#idAddr").val();//身份证详细地址
        data["issuingOrg"] = $("#issuingOrg").val();//证件签发机关
        data["postAddr"] = $("#postAddr").val();//家庭地址详细地址
        data["nation"] = $("#nation").val();//民族
        data["certValidSDt"] = $("#certValidSDt").val();//证件有效起始日期
        if (null == certValidEDt) {
            data["certValidEDt"] = $("#certValidEDt").val();//身份证截止日期
        } else {
            data["certValidEDt"] = certValidEDt;
        }
        data["monthInc"] = $("#monthInc").val();//月收入
        data["indCd"] = $("#indCd").val();//行业
        data["highDgCd"] = $("#highDgCd").val();//学历
        var url = '<%=path%>/institution/ylbank/ylBankPrjAccInfo.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    UIUtils.alertSuccessHold1(msg.info);
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }

    //选择长期置灰时间控件
    function enduring(checkbox) {
        if ($("#checkOne").is(':checked')) {
            $("#certValidEDt").hide();
            certValidEDt = "长期";
        } else {
            $("#certValidEDt").show();
            certValidEDt = null;
        }
    }
</script>

</body>
</html>